package org.lc.design.samples.case1;

import org.lc.design.samples.case1.strategy.AccessControlStrategy;
import org.lc.design.samples.case1.strategy.impl.AccessCardRecognitionStrategy;
import org.lc.design.samples.case1.strategy.impl.FaceRecognitionStrategy;
import org.lc.design.samples.case1.strategy.impl.IDCardRecognitionStrategy;
import org.lc.design.samples.case1.strategy.impl.QRCodeRecognitionStrategy;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 出入口控制服务
 *
 * @author lc
 * @date 2024/7/5
 */
public class AccessControlService {

    private List<AccessControlStrategy> accessControlStrategies = Arrays.asList(
            new FaceRecognitionStrategy(),
            new AccessCardRecognitionStrategy(),
            new IDCardRecognitionStrategy(),
            new QRCodeRecognitionStrategy());

    /**
     * 通行
     *
     * @param accessControlMethod 出入口控制方式
     * @param userName            通行人
     * @param passTime            通行时间
     * @author lc
     * @date 2024/7/5
     */
    public void passThrough(int accessControlMethod, String userName, Date passTime) {
        for (AccessControlStrategy accessControlStrategy : accessControlStrategies) {
            if (accessControlStrategy.support(accessControlMethod)) {
                accessControlStrategy.passThrough(userName, passTime);
            }
        }
    }
}
